package rsee.com;

import com.video.h264.GlobalUtil;

public class SourceIdentNet extends SourceIdent {
	private String mRecord = null;
	private byte mChanIndex = 0;
	private byte[] mChannelGroupIndex;
	private int Version = 1;
	protected SourceIdentNet (String record, byte chanIndex) {
		super();
		
		if (null == record)
		    mRecord = new String();
		else
		    mRecord = new String(record);
		
		mChanIndex = (chanIndex >= 0) ? chanIndex : 0;
	}
	
	protected SourceIdentNet () {
		super();
	}
	
	@Override
	protected void copy(SourceIdent obj) {
		super.copy(obj);
		
		SourceIdentNet objNet = (SourceIdentNet)obj;
		
		mRecord = new String(objNet.mRecord);
	}
	
	@Override
	public void setChannelGroupIndex(byte[] channelGroupIdex)
	{
		mChannelGroupIndex = channelGroupIdex;
	}
	
	@Override
	public byte[] getChannelGroupIdex()
	{
		return mChannelGroupIndex;
	}
	
//	public String getHost() {
//		return mHost;
//	}
//	
//	public short getPort() {
//		return mPort;
//	}
//	
//	public String getUser() {
//		return mUser;
//	}
//	
//	public String getPassword() {
//		return mPassword;
//	}
//	   
//    public byte getChanTotal() {
//        return mChanTotal;
//    }
//    
//    public void setChanTotal(byte chanTotal) {
//        mChanTotal = chanTotal;
//    }
//    
	@Override
	public byte getChanIndex() {
		return mChanIndex;
	}
	
	public void setChanIndex(byte chanIndex) {
		mChanIndex = chanIndex;
	}
	
	@Override
	public int getVersion()
	{
		return Version;
	}
	
	@Override
	public void setVersion(int ver)
	{
		Version = ver;
	}
	
	@Override
	public boolean isSameIdent(Object obj) {		
		if (this == obj)
			return true;	
		if ((null == obj) || obj.getClass() != this.getClass())
			return false;		
		SourceIdentNet other = (SourceIdentNet)obj;
		// TODO optimize		
		if (!other.mRecord.equalsIgnoreCase(mRecord))
			return false;		
		if(other.Version!=Version||Version==0)
			return false;
		if(Version==1)
		{
			if(other.mChanIndex != mChanIndex&&!GlobalUtil.OVSIMoreStream)
				return false;
		}
		else if(Version ==2)
		{
			if(other.mChanIndex != mChanIndex)
				return false;
		}
		return true;
	}
}
